package com.zhentao.common;

/**
 * @author : mgh
 * @date : 2024-07-02 9:52
 * @effect : 当前类的作用是
 * @projectTeam :
 */
public class ThreadLocalUtil {
    //提供ThreadLocal 对象
    private static final ThreadLocal THREAD_LOCAL = new ThreadLocal();
    //根据键获取值 提供泛型T 根绝存储的类型 强转成对应的类
    public static <T> T get(){
        return (T) THREAD_LOCAL.get();
    }
    //存储键值对
    public static void set(Object value){
        THREAD_LOCAL.set(value);
    }
    //清除 ThreadLocal 防止内存泄漏
    public static void remove(){
        THREAD_LOCAL.remove();
    }
}
